<?php
// 本类由系统自动生成，仅供测试用途
class IndexAction extends globalAction {

	function test(){
		  $TMPL_PARSE_STRING = C('TMPL_PARSE_STRING');
		echo $TMPL_PARSE_STRING['__UCHOME__'];
	}

	public function index() {

        /**
		//周边游索引
        $this->assign('ZhouBianYouIndex', ZhouBianYouIndex(__FromDestID__));
        //国内游索引
        $this->assign('GuoNeiYouIndex', GuoNeiYouIndex(__FromDestID__));
        //出境游索引
        $this->assign('ChuJingYouIndex', ChuJingYouIndex(__FromDestID__));
        //自助游索引（含国内和出境）
        $this->assign('ZiZhuYouIndex', ZiZhuYouIndex(__FromDestID__));
        //包团游索引（含国内周边包团游,国内包团游,出境包团游）
        $this->assign('BaoTuanYouIndex', BaoTuanYouIndex(__FromDestID__));

		//获取线路列表**********************************************************
		$field = array(
            '*',
            "(select count(*) from ".C("DB_PREFIX")."pinglun where pinglun2=tour0)" => "pinglunnum"
        );
        $order = array(
            'tour42'=>'desc',
            'tour43'=>'desc',
            'tour48'=>'desc'
        );
        $limit = 10;
        //必须符合：[当前出发地][已审核]的[热门][中文]线路
        $condition["tour10"] = array("like", "%," . __FromDestID__ . ",%");//出发地
        $condition["tour44"] = array("eq",1212);//已审核
        $condition["tour41"] = array("eq","cn");//中文

		//热门线路************************************************
		$_condition = array();
        $_condition["tour4"] = array("in",array(544,563));//国内和出境线路
        $_condition["tour13"] = array("like","%,1285,%");//热门
        $hottour_common = M("tour")
            ->field($field)
            ->where(array_merge($condition,$_condition))
            ->order($order)
            ->limit($limit)
            ->select();
        trace('热门线路查询语句',M("tour")->getLastSQL());//debug
    	$this->assign("hottour_common", $hottour_common);

        //周边游************************************************
		$_condition = array();
        $_condition["tour4"] = array("eq",544);//国内线路
        $_condition["tour40"] = array("like",'%,1273,%');//周边游
        $hottour_zhoubian = M("tour")
            ->field($field)
            ->where(array_merge($condition,$_condition))
            ->order($order)
            ->limit($limit)
            ->select();
        trace('周边游查询语句',M("tour")->getLastSQL());//debug
    	$this->assign("hottour_zhoubian", $hottour_zhoubian);

		//国内游
        $_condition = array();
        $_condition["tour4"] = array("eq",544);
        $hottour_guonei = M("tour")
            ->field($field)
            ->where(array_merge($condition,$_condition))
            ->order($order)
            ->limit($limit)
            ->select();
        trace('国内游查询语句',M("tour")->getLastSQL());//debug
    	$this->assign("hottour_guonei", $hottour_guonei);

		//出境游
        $_condition = array();
        $_condition["tour4"] = array("eq",563);
        $hottour_chujing = M("tour")
            ->field($field)
            ->where(array_merge($condition,$_condition))
            ->order($order)
            ->limit($limit)
            ->select();
        trace('出境游查询语句',M("tour")->getLastSQL());//debug
    	$this->assign("hottour_chujing", $hottour_chujing);
        */

        /***********************************************************************
         * 线路列表
         **********************************************************************/
        global $SYS_config;
        $indextour = S('indextour' . __FromDestID__);
        if(empty($indextour)) {
            //$lead = urlencode( iconv("UTF-8", "gb2312", __FromDestName__) );
            $lead = __FromDestName__;
            $tourtypeArray = array('hot','zhoubian','guonei','chujing');

            foreach($tourtypeArray as $tourtype) {
                $url = $SYS_config['Gettourxoldurl']."/xdreams.asp"
                     . "?lead={$lead}&tourtype={$tourtype}&limit=23";
                $tour[$tourtype] = file_get_contents($url);

                $tour[$tourtype] = iconv('GB2312', 'UTF-8', $tour[$tourtype]);
            }

            $indextour = $tour;
            S('indextour' . __FromDestID__ , $indextour, 3600);
        }
        $this->assign('indextour', $indextour);

        /***********************************************************************
         * 客栈列表
         **********************************************************************/
        $innDao = D('Inn');
        //查询条件
        $condition = array();
        $condition[$innDao->_map['menuId']] = 585;//客栈数据标志
        $condition[$innDao->_map['status']] = 1212;//审核标志
        //$condition[$innDao->_map['area']] = ;//所属地区
        //排序
        $order = array();
        $order[$innDao->_map['status']] = 'asc';
        //查询数据
        $innList = $innDao->unionField()
            ->where($condition)
            ->limit(5)
            ->order($order)
            ->select();
        $this->assign('innList', $innList);

        /***********************************************************************
         * 热门攻略目的地
         **********************************************************************/
        $blog_dest_dao = M('destination',UHDQ);
        $blog_dest_list = $blog_dest_dao
            ->field('id,name')
            ->order('hot desc')
            ->limit(30)
            ->select();
        $this->assign('blog_dest_list', $blog_dest_list);

        $this->display();
    }
}